//package com.cr.admin.base.interceptor;
//
//import cn.dev33.satoken.stp.StpUtil;
//import cn.hutool.json.JSONUtil;
//import com.cr.common.response.StatusCode;
//import com.cr.common.response.JsonResult;
//import org.springframework.http.MediaType;
//import org.springframework.web.servlet.HandlerInterceptor;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
//public class LoginInterceptor implements HandlerInterceptor {
//
//    @Override
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//
//        if (!StpUtil.isLogin()) {
//            response.setContentType(MediaType.APPLICATION_JSON_VALUE);
//            response.setCharacterEncoding("UTF-8");
//            JsonResult result = JsonResult.error(StatusCode.UNAUTHORIZED, "请登录~");
//            response.getWriter().write(JSONUtil.toJsonStr(result));
//            return false;
//        }
//        return true;
//    }
//
//}
